package com.wkg.lotterysystem.common.exception;


import com.wkg.lotterysystem.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

//不写@EqualsAndHashCode(callSuper = true)可以会出现问题
@Data
@EqualsAndHashCode(callSuper = true) // 正确继承 RuntimeException 的 equals 和 hashCode
public class ControllerException extends RuntimeException {

    private int code;         // 错误码
    private String message;   // 错误信息

    public ControllerException() {
    }

    public ControllerException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }


    public ControllerException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }
}
